home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / select1.fr_ / select1.fr
Text File  |  1995-07-04  |  4KB  |  132 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Simple SELECTer"
  5.    ClientHeight    =   4665
  6.    ClientLeft      =   225
  7.    ClientTop       =   1815
  8.    ClientWidth     =   7575
  9.    Height          =   5070
  10.    Left            =   165
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4665
  13.    ScaleWidth      =   7575
  14.    Top             =   1470
  15.    Width           =   7695
  16.    Begin VB.CommandButton cmdClose 
  17.       Caption         =   "Close"
  18.       Default         =   -1  'True
  19.       BeginProperty Font 
  20.          name            =   "MS Sans Serif"
  21.          charset         =   0
  22.          weight          =   700
  23.          size            =   8.25
  24.          underline       =   0   'False
  25.          italic          =   0   'False
  26.          strikethrough   =   0   'False
  27.       EndProperty
  28.       Height          =   555
  29.       Left            =   3120
  30.       TabIndex        =   2
  31.       Top             =   3780
  32.       Width           =   1335
  33.    End
  34.    Begin VB.ListBox lstTitles 
  35.       Height          =   1035
  36.       Left            =   480
  37.       TabIndex        =   1
  38.       Top             =   2160
  39.       Width           =   6555
  40.    End
  41.    Begin VB.Data Data1 
  42.       Caption         =   "Data1"
  43.       Connect         =   "Access"
  44.       DatabaseName    =   "C:\VB\BIBLIO.MDB"
  45.       Exclusive       =   0   'False
  46.       Height          =   300
  47.       Left            =   480
  48.       Options         =   0
  49.       ReadOnly        =   0   'False
  50.       RecordsetType   =   2  'Snapshot
  51.       RecordSource    =   "SELECT [Company Name] FROM [Publishers] WHERE STATE = 'NY'  ORDER BY [Company Name]"
  52.       Top             =   1800
  53.       Visible         =   0   'False
  54.       Width           =   2115
  55.    End
  56.    Begin MSDBCtls.DBList dblPublishers 
  57.       Bindings        =   "SELECT1.frx":0000
  58.       Height          =   1035
  59.       Left            =   480
  60.       TabIndex        =   0
  61.       Top             =   360
  62.       Width           =   5175
  63.       _Version        =   65536
  64.       _ExtentX        =   9128
  65.       _ExtentY        =   1826
  66.       _StockProps     =   77
  67.       BackColor       =   -2147483643
  68.       MatchEntry      =   1
  69.       ListField       =   "Company Name"
  70.       BoundColumn     =   "Name"
  71.       MouseIcon       =   "SELECT1.frx":000E
  72.    End
  73. End
  74. Attribute VB_Name = "Form1"
  75. Attribute VB_Creatable = False
  76. Attribute VB_Exposed = False
  77. Option Explicit
  78.  
  79. ' Change the following to point to your copy of BIBLIO.MDB.
  80.  
  81. Private Sub Form_Load()
  82.     Dim db As DATABASE
  83.     Dim dbName As String
  84.     Dim rs As Recordset
  85.     Dim sql As String
  86.  
  87.     ' Set up the error handler.
  88.  
  89.     On Error GoTo FormLoadError
  90.  
  91.     ' Get the database name and open the database.
  92.     dbName = BiblioPath()       ' BiblioPath is a function in READINI.BAS
  93.     Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
  94.     
  95.     ' Open a snapshot-type recordset on the [Titles] Table, selecting only
  96.     ' those titles published in 1993 or 1994. Sort the records by the ISBN
  97.     ' number.
  98.  
  99.     sql = "SELECT [Title],[ISBN] FROM [Titles]"
  100.     sql = sql & " WHERE [Year Published] = 1993 OR [Year Published] = 1994"
  101.     sql = sql & " ORDER BY [ISBN]"
  102.     Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
  103.  
  104.     ' If there is at least one record in the recordset, move through the
  105.     ' recordset a record at a time until the end of the file (EOF) is
  106.     ' reached. Display each record in the unbound list box lstTitles.
  107.  
  108.     If rs.RecordCount > 0 Then
  109.         rs.MoveFirst
  110.         Do While Not rs.EOF
  111.             lstTitles.AddItem rs![ISBN] & ": " & rs![Title]
  112.             rs.MoveNext
  113.         Loop
  114.     End If
  115.  
  116. Exit Sub
  117.  
  118. FormLoadError:
  119.  
  120.     ' Just display Visual Basic's default error message.
  121.  
  122.     MsgBox Error(Err)
  123.  
  124. Exit Sub
  125.  
  126. End Sub
  127.  
  128. Private Sub cmdClose_Click()
  129.     End
  130. End Sub
  131.  
  132.